package com.sdust.utils;

import com.sdust.pojos.vo.WxLoginGetVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.util.Map;

/**
 * Http请求工具类
 */
@Component
public class HttpClientUtil {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 向微信code2Session接口发送请求
     * @param url
     * @param paramMap
     * @return
     */
    public WxLoginGetVo doGet(String url, Map<String,String> paramMap) {

        //向微信服务器发送请求，参数分别为：请求的url，请求解析后封装的类，传递参数(此处用map封装）
        ResponseEntity<WxLoginGetVo> entity = restTemplate.getForEntity(url, WxLoginGetVo.class, paramMap);

        WxLoginGetVo wxLoginGetVo = entity.getBody();

        return wxLoginGetVo;
    }


}
